package mines.fila3.letstalk.tools;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class InputStreamConverter {

	public static Boolean convertToBoolean(InputStream is) {
		String line = "";
		StringBuilder builder = new StringBuilder();
		BufferedReader rd = new BufferedReader(new InputStreamReader(is));

		try {
			while ((line = rd.readLine()) != null) {
				builder.append(line);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		return "true".equals(builder.toString().toLowerCase());
	}

	public static String convertToString(InputStream is) {
		String line = "";
		StringBuilder builder = new StringBuilder();
		BufferedReader rd = new BufferedReader(new InputStreamReader(is));

		try {
			while ((line = rd.readLine()) != null) {
				builder.append(line);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		return builder.toString();
	}
}